﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="msBsc.WebUi.wfAddRecommendation"
    CodeBehind="wfAddRecommendation.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>添加资讯信息</title>
    <link href="/jqPlugin/jqTab/ui.tabs.css" rel="stylesheet" type="text/css" />

    <script src="/jqPlugin/jqTab/ui.tabs.js" type="text/javascript"></script>

    <link href="/jqPlugin/kindeditor/themes/default/default.css" type="text/css" rel="stylesheet" />
    <link href="/jqPlugin/hdfu/hdfu.css" rel="stylesheet" />
    <link href="/jqPlugin/SelectSimu/css/base.css" rel="stylesheet" />
    <script src='/??jqPlugin/kindeditor/kindeditor.js,jqPlugin/kindeditor/lang/zh_CN.js'
        type='text/javascript'></script>
    <style type="text/css">
        html, body {
            overflow: hidden;
            margin-left: 0px;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
        }

        * {
            font-family: 微软雅黑;
            font-size: 14px;
        }

        input[type=text] {
            height: 25px;
            width: 160px;
        }

        .select .selectInput {
            width: 80px !important;
        }

        #outerInner, #province, #city {
            display: block;
            width: 80px !important;
            float: left;
            margin-right: 10px;
            z-index: 99 !important;
        }

        #selectType {
            width: 80px;
            height: 25px;
        }

        #isPushTop {
            width: 60px;
            height: 25px;
        }

        #btnSubmit, #btnReset, #btnPreview {
            width: 60px;
            height: 30px;
        }

        .coverDiv {
            width: 100%;
            height: 100%;
            background-color: #000;
            opacity: 0.8;
            filter: alpha(opacity=80);
            position: absolute;
            z-index: 900;
            display: none;
        }

        .prevContent {
            width: 1000px;
            height: 800px;
            background-color: #fff;
            opacity: 1 !important;
            margin: 10px auto;
            position: absolute;
            display: none;
            z-index: 999;
            left: 20%;
        }

        #showMsg {
            padding: 10px 20px;
            position: absolute;
            border: 3px solid #a2bcee;
            border-radius: 5px;
            background-color: #fff;
            left: 30%;
            top: 50%;
            display: none;
            min-width: 120px;
            min-height: 60px;
            text-align: center;
            vertical-align: middle;
        }

        #imgHead img {
            width: 100px;
            height: 100px;
        }
    </style>
    <script src="/jqPlugin/js/jBase.js"></script>
    <script src="/jqPlugin/js/jBPage.js"></script>
    <script src="/jqPlugin/js/laytpl.js"></script>
    <script src="/jqPlugin/SelectSimu/js/SelectSimu.js"></script>
    <!--end JS引用-->


</head>
<body style="overflow: scroll">
    <div class="coverDiv">
    </div>
    <div class="prevContent">
    </div>
    <div id="showMsg">
    </div>
    <table>
        <tr>
            <td>选择发布类型：</td>
            <td>
                <select id="selectType">
                    <option value="1">景区</option>
                    <option value="2">美食</option>
                    <option value="3">购物</option>
                </select></td>
        </tr>
        <tr>
            <td>选择发布地址：</td>
            <td>
                <div class="search">
                    <span id="outerInner" class="select"></span>
                    <span id="province" class="select"></span>
                    <span id="city" class="select"></span>
                </div>
            </td>
        </tr>
        <tr>
            <td>名  称：</td>
            <td>
                <input type="text" id="txtRecommName" value="" />
            </td>
        </tr>
        <tr>
            <td>地  址：</td>
            <td>
                <input type="text" id="txtRecommAddr" value="" />
            </td>
        </tr>
        <tr>
            <td>价  格：</td>
            <td>
                <input type="text" id="txtRecommPrice" value="" />
            </td>
        </tr>
        <tr>
            <td>是否推荐:</td>
            <td>
                <select id="isPushTop">
                    <option value="1">是</option>
                    <option value="0">否</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>封面图片：</td>
            <td>
                <div style="width: 100px; height: 100px; border: 3px solid #cecaca; cursor: pointer" class="uploadbox" data-value="scenic" data-count="0" id="imgHead">
                    点击选择图片
                </div>
            </td>
        </tr>
        <tr>
            <td>概况介绍：</td>
            <td>
                <div class="txtEditor">
                    <textarea name="content" id="forumInfo" style="height: 400px"></textarea>
                </div>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" id="btnPreview" value="预  览" />
                <input type="button" id="btnSubmit" value="提  交" />
                <input type="button" id="btnReset" value="重  置" /></td>
        </tr>
    </table>
    <div class="ui-mask"></div>
    <div id="altContent" style="top: 10px;"></div>

    <script src="/jqPlugin/hdfu/hdfu.js"></script>
    <script type="text/ecmascript">
        $("#selectType").change(function () {
            var uploadType = $(this).val();
            var picDataValue = "scenic";
            if (uploadType == 1) {
                picDataValue = "scenic";
            }
            else if (uploadType == 2) {
                picDataValue = "food";
            }
            else if (uploadType == 3) {
                picDataValue = "specialty";
            }
            else {
                alert("请选择正确的发布类型");
                return;
            }

            $("#imgHead").attr("data-value", picDataValue);
        })

        $("#btnReset").click(function () {
            PageReset();
        })

        $("#btnSubmit").click(function () {
            var ErrMsg = ComfirmInput();
            if (ErrMsg != "") {
                ShowMessage("true", ErrMsg);
                return;
            }
            btnDo("AddRecomm");
        })

        $("#btnPreview").click(function () {
            var prevHtml = GetPageContentToDiv();
            $(".prevContent").html(prevHtml);
            $(".coverDiv, .prevContent").show();
        })

        $(".coverDiv,.prevContent").click(function () {
            $(".coverDiv").hide();
            $(".prevContent").hide();
        })

        function ShowMessage(isErr, message) {
            debugger;
            if (isErr == "true") {
                $("#showMsg").css("border", "3px solid #eebca2").css("color", "#eeaaaa");
            }
            else {
                $("#showMsg").css("border", "3px solid #a2bcee").css("color", "#000");
            }
            $("#showMsg").text(message);

            $("#showMsg").show().animate({ top: '-=' + 80 + 'px' }, 1000, function () {
                $(this).fadeOut("2000").animate({ top: '+=' + 80 + 'px' }, 100);
            })
        }

        function GetPageContentToDiv() {
            var countryName = $("#outerInner>.selectInput>span").text();
            var cityName = $("#province>.selectInput>span").text();
            var desName = $("#city>.selectInput>span").text();
            var inputType = $("#selectType").text();
            var inputName = $("#txtRecommName").val();
            var inputContent = editorContend.html();

            var showHtmlStr = "<p>资讯>" + countryName + ">" + cityName + ">" + desName + "><span style='color:#a2bcee'>" + inputName + "</span></p><p style='text-align:center'>" + inputName + "</p><div style='width:800px;margin:20px auto;height:650px;overflow:scroll;'>" + inputContent + "</div>";

            return showHtmlStr;
        }

        function ComfirmInput() {
            var ErrMsg = "";
            var inputType = $("#selectType").val();
            if (inputType != 1
                && inputType != 2
                && inputType != 3) {
                ErrMsg = "请选择正确的发布类型!";
                return ErrMsg;
            }

            var countryId = $("#outerInner>.selectInput>input").val();
            var cityId = $("#province>.selectInput>input").val();
            var desId = $("#city>.selectInput>input").val();
            if (InputIsNull(countryId)
                || InputIsNull(countryId)
                || InputIsNull(countryId)) {
                ErrMsg = "上传地区不能为空!";
                return ErrMsg;
            }
            var inputName = $("#txtRecommName").val();
            if (InputIsNull(inputName)) {
                ErrMsg = "资讯名称不能为空!";
                return ErrMsg;
            }
            var defaultPic = $("#imgHead img").attr("src");
            if (InputIsNull(defaultPic)) {
                ErrMsg = "封面图片不能为空!";
                return ErrMsg;
            }
            var inputContent = editorContend.html();
            if (InputIsNull(inputContent) || inputContent == "<br />") {
                ErrMsg = "资讯内容不能为空!";
                return ErrMsg;
            }
            return ErrMsg;
        }


        function InputIsNull(data) {
            if (data == '' || data == null || data == undefined) {
                return true;
            }
            return false;
        }

        function PageReset() {
            var addrStr = $("#txtRecommAddr").val();
            $("input[type=text]").val("");
            $("#txtRecommAddr").val(addrStr);
            $("#imgHead").html("点击选择图片");
            editorContend.html("");
        }

        K = KindEditor;
        //        K.DEBUG = true;
        K.basePath = K.options.basePath = '/jqPlugin/kindeditor/';
        K.options.themesPath = K.options.basePath + 'themes/';
        K.options.langPath = K.options.basePath + 'lang/';
        K.options.pluginsPath = K.options.basePath + 'plugins/';
        function getfilequery() {
            return "&ParentId=" + "&FileId=" + ""
                                    + "&RelId=" + ""
                                    + "&rType1=" + "0"
                                    + "&rType2=" + "0";
        };

        var editorContend;
        function SetEditHtml(_sHtml) {
            scontenthtml = _sHtml;
        };
        var scontenthtml = '';
        $(window).load(function () {

            editorContend = K.create('#forumInfo', {
                allowFileManager: true,
                resizeType: 0,
                allowPreviewEmoticons: true,
                allowImageUpload: true,
                loadStyleMode: false,
                designMode: true,
                afterCreate: function () {

                }
            });
            editorContend.fileManagerJson = '/pgajax.axd?F_MANA=1&rType1=0&rType2=0&COOKATHID=' + (typeof (cookesc) == "undefined" ? "" : cookesc)
                                    + "&fType=" + "mana";
            editorContend.uploadJson = '/pgajax.axd?F_UPLOAD=1&blSave=1&COOKATHID=' + (typeof (cookesc) == "undefined" ? "" : cookesc)
                                    + "&fType=" + "mana"
                                    + getfilequery();
            editorContend.sync("forumInfo");
            editorContend.html(scontenthtml);

            $.ploadFile("layer", function (script, textStatus) {
                //                layer.load('加载中'); 
            });
        });



        function btnDo(sEbtn) {
            GtGrid1Action = sEbtn;
            var opart = GetGtParam("myGrid1");
            if (sEbtn == "mFinder") {
                doFinderGt('myGrid1');
            }
            else if (sEbtn == "btnEdit") {
                opart.AddCell("sEditMode", "EDIT");
                ajaxComm(opart, null, null, 'divCondition'); //调用页面回调，并传入参数
            }
            else if (sEbtn == "btnSave") {
                doSaveGt('myGrid1');
            }
            else if (sEbtn == "btnConfirm" || sEbtn == "btnCancel") {
                var sidtem1 = GetGtSelectId('myGrid1');
                if (sidtem1) {
                    opart.AddCell("CHECK_ID", sidtem1);
                    ajaxComm(opart, null, null, 'divCondition'); //调用页面回调，并传入参数
                } else {
                    alert("请先选择记录！");
                }
            }
            else if (sEbtn == "AddRecomm") {
                opart.AddCell("recommType", $("#selectType").val());
                opart.AddCell("recommTitle", $("#txtRecommName").val());
                opart.AddCell("recommAddr", $("#txtRecommAddr").val());
                opart.AddCell("recommPrice", $("#txtRecommPrice").val());
                opart.AddCell("recommPic", $("#imgHead img").attr("src"));
                opart.AddCell("recommIsPush", $("#isPushTop").val());
                opart.AddCell("recommContent", editorContend.html());
                ajaxComm(opart, null, null, 'divCondition');
            }
            else {
                ajaxComm(opart, null, null, 'divCondition'); //调用页面回调，并传入参数
            }
            GtGrid1Action = "";
        };


        setArea("outerInner", 200, 1, 1, ["DF6723BE-A25C-4F77-BB49-A1662D3E6F2A"], ["中国"]);
        setArea("province", 200, 2, 1, ["AEF39D8E-D298-4AF1-AEC5-2B00D237F5F5"], ["北京"]);
        setArea("city", 200, 3, 1, [""], ["全部"]);
        var parentsId = "00000000-0000-0000-0000-000000000000";
        var GtGrid1Action;

        function setArea(input, width, zIndex, listNum, listValue, listOption) {
            $("#" + input).SelectSimu({
                width: width,
                zIndex: zIndex,
                listNum: listNum,
                listValue: listValue,
                listOption: listOption,
                imgSrc: '/jqPlugin/SelectSimu/img/icon_down.png'
            })
        }

        var currentOuterInnerId = "";
        var currentProvinceId = "";

        //收索按钮
        function search() {
            var outerInner = $("#outerInner input").val();
            var province = $("#province input").val();
            var city = $("#city input").val();
            if (outerInner == undefined || outerInner == null) {
                outerInner = ""
            }
            if (province == undefined || province == null) {
                province = ""
            }
            if (city == undefined || city == null) {
                city = ""
            }
            window.location.href = "/wp_VehicleList.htm?countryId=" + outerInner + "&cityId=" + province + "&destionId=" + city;
        }

        function updateSelet(inputId, valueData) {
            var selectValue = $("#" + inputId + " .selectList ul");
            selectValue.html("");
            var data = eval(valueData);
            for (var i = 0; i < data.length; i++) {
                selectValue.append('<li data-value="' + data[i].ID + '">' + data[i].Name + '</li>');
            }
            if (data.length > 0) {
                $("#" + inputId + " input").val(data[0].ID);
                $("#" + inputId + " span").text(data[0].Name);
            }
        }


        function GetGtParam(jqGridID) {
            var _jsParam = new jsonRow();
            if (jqGridID == "myGrid1") {
                GetFormJson("divCondition", _jsParam);
                _jsParam.AddCell("PPAGE", "wfConstantHandle"); //这个地方是该页面的类名
                _jsParam.AddCell("gtGridID", "myGrid1");
                _jsParam.AddCell("sRadom", $("#sRadom").val());
                _jsParam.AddCell("selectType", $("#selectType").val());
                _jsParam.AddCell("ACTION", GtGrid1Action);
                _jsParam.AddCell("parentsId", parentsId);
                _jsParam.AddCell("isAll", jqGridID);
                _jsParam.AddCell("countryId", $("#outerInner>.selectInput>input").val());
                _jsParam.AddCell("cityId", $("#province>.selectInput>input").val());
                _jsParam.AddCell("destinationId", $("#city>.selectInput>input").val());
                //这里可增加传入后台的参数
            } return _jsParam;
        };
        (function () {

            //jQuery.loadHtml('/pgajax.axd?GETLOGIN=1').done(function (_rets) {
            //    if (_rets) { $("#divLoginInfo").html(_rets); }
            //});


            $('#outerInner .selectList li').live('click', function () {
                var outerInnerId = this.getAttribute('data-value');
                if (currentOuterInnerId == outerInnerId) {
                    return;
                }
                currentOuterInnerId = outerInnerId;
                parentsId = outerInnerId;
                btnDo("getArea2");
            });
            $('#province .selectList li').live('click', function () {
                var provinceId = this.getAttribute('data-value');
                if (provinceId == currentProvinceId) {
                    return;
                }
                currentProvinceId = provinceId;
                parentsId = provinceId;
                btnDo("getArea3");
            });
        })();
        btnDo("initplace");
    </script>
</body>
</html>

